package com.biz.primus.ms.commodity.trans;

import com.biz.primus.commodity.vo.backend.CategoryListItemVo;
import com.biz.primus.ms.commodity.dao.po.Category;
import com.google.common.base.Function;

/**
 * 转换器(Category ---> CategoryListItemVo)
 *
 * @author 江南
 * @usage
 * @reviewer
 * @since 2016/12/19
 */
public class Category2CategoryListItemVo implements Function<Category, CategoryListItemVo> {

    @Override
    public CategoryListItemVo apply(Category category) {
        CategoryListItemVo categoryListItemVo = new CategoryListItemVo();
        categoryListItemVo.setId(String.valueOf(category.getId()));
        categoryListItemVo.setName(category.getName());
        categoryListItemVo.setIdx(category.getIdx());
        categoryListItemVo.setCreateTimeStamp(category.getCreateTimestamp());
        categoryListItemVo.setStatus(category.getStatus());
        categoryListItemVo.setCategoryLevel(category.getLevel());
        if (category.getParent()!=null){
            categoryListItemVo.setParentName(category.getParent().getName());
        }
        if((category.getChildren()).size() == 0){
        	categoryListItemVo.setShowDel("true");
        } else {
        	categoryListItemVo.setShowDel("false");
        }
        return categoryListItemVo;
    }
}
